package com.niknik.woody.utils.wunit.junit.rule; /**
 * User: yoda
 * Date: 12.12.11
 * Time: 3:06
 */

import org.junit.rules.ExpectedException;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;

import java.text.MessageFormat;

import static org.hamcrest.core.Is.is;

@Deprecated
public class WExpectedException
    implements TestRule {

  private ExpectedException delegate = ExpectedException.none();

  public void expect(Class<? extends Throwable> clazz, String msg, String... params) {
    delegate.expect(clazz);
    if (msg != null) {
      delegate.expectMessage(is(MessageFormat.format(msg, params)));
    }
  }

  @Override
  public Statement apply(Statement base, Description description) {
    return delegate.apply(base, description);
  }
}